﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_Flow_FaileDocument]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_Flow_FaileDocument];
GO
CREATE PROCEDURE [dbo].[sproc_Flow_FaileDocument]
    @DocID int
AS

Delete FROM uds_flow_status
    WHERE doc_id = @DocID

--删除真正的消息
DELETE FROM UDS_SMS_MobileMsgSendBuffer        
    WHERE     msgid in (
                SELECT     msgid 
                    FROM 
                        uds_flow_message
                    WHERE     doc_id = @docid

              )

--删除当前文档的提醒
DELETE FROM uds_flow_message
    WHERE     doc_id = @docid

UPDATE uds_flow_document
    SET doc_status = 4
    WHERE doc_id = @DocID